// Copyright (c) 2009 Luca Marrocco.
// Modified or written by Luca Marrocco for inclusion with codej.
// Licensed under the Apache License, Version 2.0 (the "License")
package codej.gen;

import java.util.*;

/** @author Luca Marrocco */
public class Tokens {

	private Map<String, Token> tokens;

	public Tokens() {
		this.tokens = new HashMap<String, Token>();
	}

	public Token getToken(String name) {
		if (!getTokens().containsKey(name))
			getTokens().put(name, new Token(name));

		return getTokens().get(name);
	}

	public Map<String, Token> getTokens() {
		return tokens;
	}

	public String toString() {
		StringBuffer stringBuffer = new StringBuffer();

		for (String name : tokens.keySet()) {
			stringBuffer.append(name);
			stringBuffer.append("\n");
		}

		return stringBuffer.toString();
	}
}
